#include<bits/stdc++.h>
#define ll long long
#define vc vector
#define trav(a,x) for(auto& a : x)
#define all(v) v.begin(), v.end()
#define f(p,q,r) for(ll p=q;p<r;p++)
#define fr(p,q,r) for(ll p=q;p>=r;p--)
#define sz(x) (ll)(x).size()
#define el endl
#define pb push_back
#define pp pop_back
#define max_3(a,b,c) max(a,max(b,c))
#define min_3(a,b,c) min(a,min(b,c))
#define max_4(a,b,c,d) max(a,max(b,max(c,d)))
#define min_4(a,b,c,d) min(a,min(b,min(c,d)))
#define better_one ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
const int N=105;
int a[N][N],b[N][N],c[N][N];
void solve()
{
int n,m,k;
cin >> n >> m >> k;
string s;
f(i,1,n+1){
cin >> s;
f(j,1,m+1) cin >> a[i][j] >> b[i][j] >> c[i][j];
}
auto t=[&](int x,int y)
{
bool used[m+1]={0};
int ans=0,last=k;
while(last)
{
int mx=0,ix,ct;
f(i,1,m+1){
if(used[i]) continue;
if(b[y][i]-a[x][i]>mx)
{
ix=i;
mx=b[y][i]-a[x][i];
}
}
if(mx==0) break;
ct=min(last,c[x][ix]);
ans+=ct*mx;
used[ix]=1;
last-=ct;
}
return ans;
};
int ans=0;
f(i,1,n+1)
{
f(j,1,n+1) ans=max(ans,t(i,j));
}
cout<<ans;
}
int main ()
{
cout << el;
better_one;
int t=1;
// cin >> t;
while(t--)
{
solve();
}
return 0;
}
236A - Boy or Girl | 271A - Beautiful Year |
520B - Two Buttons | 231A - Team |
479C - Exams | 1030A - In Search of an Easy Problem |
158A - Next Round | 71A - Way Too Long Words |
160A - Twins | 1A - Theatre Square |
1614B - Divan and a New Project | 791A - Bear and Big Brother |
1452A - Robot Program | 344A - Magnets |
96A - Football | 702B - Powers of Two |
1036A - Function Height | 443A - Anton and Letters |
1478B - Nezzar and Lucky Number | 228A - Is your horseshoe on the other hoof |
122A - Lucky Division | 1611C - Polycarp Recovers the Permutation |
432A - Choosing Teams | 758A - Holiday Of Equality |
1650C - Weight of the System of Nested Segments | 1097A - Gennady and a Card Game |
248A - Cupboards | 1641A - Great Sequence |
1537A - Arithmetic Array | 1370A - Maximum GCD |